<!DOCTYPE html>
<html>
<head>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=1" name="viewport" />
    <title><%=title%></title>
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="http://apps.bdimg.com/libs/fontawesome/4.2.0/css/font-awesome.min.css">
</head>
<body ng-app="boardApp">

<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <div class="container-fluid" ng-controller="navbarController">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed"
                    data-toggle="collapse" data-target="#navbar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="javascript:void(0)" style="color: white;"><%=title%></a>
        </div>
        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="navbar-collapse">
            <ul class="nav navbar-nav">
                <li ng-class="{active: $route.current.activeSideTab == 'home'}">
                    <a href="#home" onclick="$('#navbar-collapse').collapse('hide')">首页</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li class="dropdown" ng-show="userinfo.auth==0">
                    <a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">管理 <span class="caret"></span></a>
                    <ul class="dropdown-menu" role="menu">
                        <li ng-class="{active: $route.current.activeSideTab == 'user'}">
                            <a href="#user" onclick="$('#navbar-collapse').collapse('hide')">人员管理</a></li>

                    </ul>
                </li>
                <li><a href="#login" ng-click="logout()">退出</a></li>
            </ul>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>

<div class="layout-body" ng-view></div>

<%-include _partial/utils.ejs%>

<script type="text/ng-template" id="template-user.html">
    <h2 style="text-align: center;" ng-hide="editting">人员管理</h2>
    <div class="btn-group" style="margin-bottom: 10px;" ng-hide="editting||userinfo.auth!=0">
        <button type="button" class="btn btn-success" ng-click="editBtn()" ng-disabled="checked">
            <i class="fa fa-plus"></i> 新建
        </button>
        <button type="button" class="btn btn-warning" ng-click="editBtn()" ng-disabled="checkEdit()">
            <i class="fa fa-edit"></i> 编辑
        </button>
        <button type="button" class="btn btn-danger" ng-click="delete()" ng-disabled="checkEdit()">
            <i class="fa fa-times"></i> 删除
        </button>
        <button type="button" class="btn btn-primary" ng-click="reset()">
            <i class="fa fa-refresh"></i> 刷新
        </button>
    </div>
    <div class="edit-div" ng-show="editting">
        <h3 style="text-align: center;">{{checked?'编辑人员':'新建人员'}}</h3>
        <form class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3 col-lg-4 col-lg-offset-4"
              name="stationForm" role="form">
            <div class="form-group">
                <label>登录名 <span class="label label-danger"><i class="fa fa-asterisk"></i></span></label>
                <input type="text" ng-model="_f.username" class="form-control" placeholder="" ng-readonly="checked" required>
            </div>
            <div class="form-group">
                <label>角色 <span class="label label-danger"><i class="fa fa-asterisk"></i></span></label>
                <select ng-model="_f.auth" class="form-control" placeholder="" required>
                    <option value="">-请选择角色-</option>
                    <option value="0">管理员</option>
                    <option value="1">操作员</option>
                </select>
            </div>
            <div class="form-group" ng-show="checked">
                <label>旧密码</label>
                <input ng-model="_f.password1" id="password1" type="password" class="form-control"
                       ng-minlength="6"  placeholder="请输入您的密码"/>
            </div>
            <div class="form-group">
                <label>新密码 <span class="label label-danger" ng-show="!checked||_f.password1">
                        <i class="fa fa-asterisk"></i></span></label>
                <input ng-model="_f.password" id="password" type="password" ng-minlength="6"
                       class="form-control" placeholder="密码要求6位以上"
                       ng-disabled="checked&&!_f.password1" ng-required="!checked||_f.password1"/>
            </div>
            <div class="form-group">
                <label>确认密码 <span class="label label-danger" ng-show="!checked||_f.password1">
                        <i class="fa fa-asterisk"></i></span></label>
                <input ng-model="_f.password2" id="password2" type="password" class="form-control"
                       ng-minlength="6"  data-equal-to="#password"
                       placeholder="请重复输入您的密码" ng-required="!checked||_f.password"
                       ng-disabled="checked&&!_f.password&&!_f.password1"/>
            </div>
            <div class="btn-group">
                <button type="submit" ng-click="submit()" ng-disabled="stationForm.$invalid" class="btn btn-success">
                    <i class="fa fa-thumbs-up"></i> 提交</button>
                <button type="button" ng-click="cancel()" class="btn btn-default">
                    <i class="fa fa-thumbs-down"></i> 取消</button>
            </div>
        </form>
    </div>
    <table class="table table-bordered table-hover" ng-hide="editting">
        <thead>
        <tr><th style="width: 30px;">#</th>
            <th>登录名</th><th>权限</th></tr>
        </thead>
        <tbody>
        <tr ng-repeat="x in list">
            <td><input type="checkbox" ng-model="x.checked"/></td>
            <td ng-click="x.checked=!x.checked;">{{x.username}}</td>
            <td ng-click="x.checked=!x.checked;">{{x.auth?'操作员':'管理员'}}</td>
        </tr>
        </tbody>
    </table>
</script>

<script type="text/ng-template" id="template-home.html">

</script>

<script src="javascripts/jquery/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="angular/angular.min.js"></script>
<script src="angular/angular-route.min.js"></script>
<script src="javascripts/socket.io.js"></script>
<script src="javascripts/util.js"></script>
<script src="javascripts/angular.controllers.js"></script>
</body>
</html>